package com.ruoyi.tongyan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tongyan.domain.TClosure;
import com.ruoyi.tongyan.service.ITClosureService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 结题管理Controller
 * 
 * @author ruoyi
 * @date 2025-04-21
 */
@RestController
@RequestMapping("/tongyan/closure")
public class TClosureController extends BaseController
{
    @Autowired
    private ITClosureService tClosureService;

    /**
     * 查询结题管理列表
     */
    @PreAuthorize("@ss.hasPermi('tongyan:closure:list')")
    @GetMapping("/list")
    public TableDataInfo list(TClosure tClosure)
    {
        startPage();
        List<TClosure> list = tClosureService.selectTClosureList(tClosure);
        return getDataTable(list);
    }

    /**
     * 导出结题管理列表
     */
    @PreAuthorize("@ss.hasPermi('tongyan:closure:export')")
    @Log(title = "结题管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TClosure tClosure)
    {
        List<TClosure> list = tClosureService.selectTClosureList(tClosure);
        ExcelUtil<TClosure> util = new ExcelUtil<TClosure>(TClosure.class);
        util.exportExcel(response, list, "结题管理数据");
    }

    /**
     * 获取结题管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('tongyan:closure:query')")
    @GetMapping(value = "/{closureId}")
    public AjaxResult getInfo(@PathVariable("closureId") Long closureId)
    {
        return success(tClosureService.selectTClosureByClosureId(closureId));
    }

    /**
     * 新增结题管理
     */
    @PreAuthorize("@ss.hasPermi('tongyan:closure:add')")
    @Log(title = "结题管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TClosure tClosure)
    {
        return toAjax(tClosureService.insertTClosure(tClosure));
    }

    /**
     * 修改结题管理
     */
    @PreAuthorize("@ss.hasPermi('tongyan:closure:edit')")
    @Log(title = "结题管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TClosure tClosure)
    {
        return toAjax(tClosureService.updateTClosure(tClosure));
    }

    /**
     * 删除结题管理
     */
    @PreAuthorize("@ss.hasPermi('tongyan:closure:remove')")
    @Log(title = "结题管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{closureIds}")
    public AjaxResult remove(@PathVariable Long[] closureIds)
    {
        return toAjax(tClosureService.deleteTClosureByClosureIds(closureIds));
    }
}
